package com.huike.service.system.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huike.dto.SysMenuPageQueryDTO;
import com.huike.dto.SysPageQueryDTO;
import com.huike.mapper.system.SysMenuMapper;
import com.huike.result.PageResult;
import com.huike.result.Result;
import com.huike.service.system.SysMenuService;
import com.huike.vo.DictionariesVO;
import com.huike.vo.SysMenuVO;
import com.huike.vo.SysMenupermsVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class SysMenuServiceImpl implements SysMenuService {
    @Autowired
    private SysMenuMapper menuMapper;

    /**
     * 分页查询
     *
     * @param queryDTO
     * @return
     */
    @Override
    public Result<List<SysMenuVO>> MenuPage(SysMenuPageQueryDTO queryDTO) {
        if (null == queryDTO) {
            System.out.println("参数为空！");
        }
        if (null == queryDTO.getPageSize() || null == queryDTO.getPageNum() || queryDTO.getPageNum() <= 0 || queryDTO.getPageSize() <= 0) {
            queryDTO.setPageNum(1);
            queryDTO.setPageSize(10);
        }
        PageHelper.startPage(queryDTO.getPageNum(), queryDTO.getPageSize());
        List<SysMenuVO> page = menuMapper.selectList(queryDTO);
        Result<List<SysMenuVO>> result = new Result<>();
        result.setCode(200);
        result.setData(page);
        result.setMsg("查询成功！");
        return result;
    }

    @Override
    public Result<List<SysMenupermsVO>> MenuPerms() {
//        menuMapper.selectPerms();
        Result<List<SysMenupermsVO>> listResult = new Result<>();
        listResult.setCode(200);
        listResult.setMsg("查询成功！");
        listResult.setData(null);
        return listResult;
    }
}
